<?php

header("content-type:text/html;chartset=utf-8");



    if( $_POST){
        
        include 'request.php';
        
        $url = '192.168.33.10/gmasiatech/merchant/process.php';
        $merchantId = $_POST['merchantId'];
        $receiver = $_POST['receiver'];
        $account_number = $_POST['account_number'];
        $bank_name = $_POST['bank_name'];
        $bank_branch = $_POST['bank_branch'];
        $reference_number = $_POST['reference_number'];
        $transactionId = $_POST['transactionId'];
        $amount =   $_POST['amount'];
        
        $sign = md5('magicMDP'.$merchantId.$transactionId.$amount);
        
	$xml_str ="xmlStr=<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
                <request>
					<method>reqFundout</method>
					<merchantId>$merchantId</merchantId>
                                        <receiver>$receiver</receiver>
                                        <account_number>$account_number</account_number>
                                        <bank_name>$bank_name</bank_name>
                                        <bank_branch>$bank_branch</bank_branch>
                                        <reference_number>$reference_number</reference_number>
                                        <transactionId>$transactionId</transactionId>
                                        <amount>$amount</amount>
					<sign>$sign</sign>
                </request>";

        
        $res2 = sendRequest($url, $xml_str);
        
        if(strpos($res2, '001') !== false){
            $desc = '请求成功.';
        }elseif(strpos($res2, '100') !== false){
            $desc = '商户不存在.';
        }elseif(strpos($res2, '101') !== false){
            $desc = '有参数无效.';
        }elseif(strpos($res2, '102') !== false){
            $desc = 'Sign验证失败.';
        }elseif(strpos($res2, '103') !== false){
            $desc = 'TransId已存在.';
        }elseif(strpos($res2, '104') !== false){
            $desc = '单次交易金额未达要求.';
        }elseif(strpos($res2, '105') !== false){
            $desc = '总交易金额未达要求.';
        }elseif(strpos($res2, '106') !== false){
            $desc = '网络错误.';
        }elseif(strpos($res2, '107') !== false){
            $desc = '交易不存在.';
        }elseif(strpos($res2, '108') !== false){
            $desc = '银行账户不存在.';
        }
        echo '<h1>';
        echo '返回值：'.$res2.'_'.$desc;
        echo '</h1>';
    }



?>

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style>
        tr{margin-bottom: 15px;}
        tr td:first-child{text-align: right;padding-right: 10px;font-weight: bold}
        form  input:not(.submit){height:30px;width:200px;}
        .readonly{border:1px solid #ccc;color:#888;}
        em{font-size: 14px;}
    </style>
</head>

<h5><a href="index.html">回到首页</a></h5>
<h3>Fund Out.</h3>
<hr>


<form action="" method="post">
<table CellSpacing=10>
   <tr><td>merchantId:</td>         <td><input type="text" name="merchantId" class="readonly" value="MDP54aa92882cd7c" readonly > <em>真实数据：商户的mdpId</em>
   <tr><td>receiver:</td>          <td><input type="text" name="receiver" value="<?php echo 'receiver_test_'.  rand(1, 1000)?>"  > <em>测试生成数据</em>
   <tr><td>account_number:</td>            <td><input type="text" name="account_number" value="<?php echo 'account_number_'.  rand(1, 1000)?>"  > <em>测试生成数据：account_number</em>
   <tr><td>bank_name:</td>          <td><input type="text" name="bank_name" class="readonly" value="ABC" readonly > <em>真实数据：平台必须有此银行</em>
   <tr><td>bank_branch:</td>          <td><input type="text" name="bank_branch"  value="<?php echo 'bankbranch_'. rand(1, 10000)?>" readonly > <em>测试生成数据：brank_branch</em>
   <tr><td>reference_number:</td>   <td><input type="text" name="reference_number" value="1"  > <em>可选</em>
   <tr><td>transactionId:</td>      <td><input type="text" name="transactionId" class="readonly" value="<?php echo 'tid_'. substr(md5(time()),5,15)?>" readonly > <em>真实数据：唯一交易ID</em>
   <tr><td>amount:</td>             <td><input type="text" name="amount" value="<?php echo rand(1, 10000)?>"  > <em>测试生成数据：交易数量，需满足商户>最低 <最高的交易要求</em>
   <tr><td>SUBMIT:</td>             <td><input type="submit" value="GO"  class="submit" >
</table>
</form>